#include <iostream>
#include <sys/time.h>
using namespace std;


double add(double x, double y)
{
    return x + y;
}

int main()
{
    struct timeval start, finish;
    size_t maxIter = 1e10;
    double a[5], b[5];
    
    gettimeofday(&start, NULL);
    size_t iter = 0;
    while(iter < maxIter)
    {
        for(size_t i = 0; i < 10000; i++)
        {
            
            double c = add(10.0, 11.0);
        }
        iter++;
    }
    gettimeofday(&finish, NULL);
    double totaltime = finish.tv_sec-start.tv_sec 
        + (finish.tv_usec-start.tv_usec) / 1000000;

    cout << "Total Elapsed: " << totaltime << " sec" << endl;

    gettimeofday(&start, NULL);
    iter = 0;
    while(iter < maxIter)
    {
        for(size_t i = 0; i < 10000; i++)
        {
            
            double c = 10.0 + 11.0;
        }
        iter++;
    }
    gettimeofday(&finish, NULL);
    totaltime = finish.tv_sec-start.tv_sec 
        + (finish.tv_usec-start.tv_usec) / 1000000;

    cout << "Total Elapsed: " << totaltime << " sec" << endl;

    return 0;
}
